# -*- coding: utf-8 -*-
"""
This file is part of tptsig
Copyright © 2011 Telecom ParisTech, TSI
Auteur(s) : Liutkus Antoine
tptsig is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU LesserGeneral Public License
along with this program. If not, see <http://www.gnu.org/licenses/>."""

from tptsig.wavfile import *
from tptsig.nmf import *
import scipy as sp
import pylab as pl

#Signal creation
sig = Signal('./data/direstraits.wav')

#computing STFT
sig.nfft = 1024
sig.overlap = 0.5
sig.STFT()

#creating NMF with 100 components
n = nmf(sig,nComponents = 100);

#computing
n.iterate(100)

#displaying results
pl.figure(1)
pl.subplot(2,1,1)
pl.imshow(log(abs(sig.stft.data[:,:,0])**2),origin='lower',aspect='auto')
pl.subplot(2,1,2)
pl.imshow(log(n.getModel().data[:,:,0]),origin='lower',aspect='auto')
pl.show()
